package cn.jji8.mysqlUse.test;

import cn.jji8.mysqlUse.mySqlSimpleUse.SqlConnect;
import cn.jji8.mysqlUse.mySqlSimpleUse.SqlTable;
import cn.jji8.mysqlUse.mySqlSimpleUse.column.Conlumn;
import cn.jji8.mysqlUse.mySqlSimpleUse.column.IntConlumn;
import cn.jji8.mysqlUse.mySqlSimpleUse.column.Operator;
import cn.jji8.mysqlUse.mySqlSimpleUse.column.TextConlumn;
import cn.jji8.mysqlUse.mySqlSimpleUse.queryCondition.QueryCondition;
import cn.jji8.mysqlUse.mySqlSimpleUse.queryResults.QueryResults;

import java.sql.SQLException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class 测试查询 {
    public static void main(String[] args) {
        System.out.println("\\asdasd'asd".replaceAll("\\\\","\\\\\\\\").replaceAll("'","\\\\'"));

        try {

            SqlConnect sqlConnect = new SqlConnect("jdbc:mysql://127.0.0.1:3306/mymc?serverTimezone=GMT&useSSL=false","root","123456789");
            Set<Conlumn> set = new HashSet<>();
            set.add(new TextConlumn("帅哥们"));
            set.add(new IntConlumn("money"));
            SqlTable sqlTable = sqlConnect.getTable("玩玩",set);

            //查询测试
            {
                Set<QueryCondition> queryConditionSet = new HashSet<>();
                queryConditionSet.add(new IntConlumn("money").getCondition(Operator.大于,6));
                QueryResults queryResults = sqlTable.query(set,queryConditionSet);
                Map<Integer,String> map = queryResults.getResults(new TextConlumn("帅哥们"));
                Map<Integer,Integer> intmap = queryResults.getResults(new IntConlumn("money"));
                System.out.println(map);
                System.out.println(intmap);
            }



            //添加测试
            /*{
                Map<Conlumn,Object> map1 = new HashMap<>();
                map1.put(new TextConlumn("帅哥们"),"小\\垃'圾");
                map1.put(new IntConlumn("money"),100);
                sqlTable.add(map1);
            }*/


            //删除测试
            //sqlTable.delete(1);

            //修改测试
            /*{
                Map<Conlumn,Object> map = new HashMap<>();
                map.put(new TextConlumn("帅哥们"),"大帅哥");
                map.put(new IntConlumn("money"),999);
                sqlTable.Update(11,map);
            }*/

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
